<?php
/*
Plugin Name:  WP Trackback for Pages
Plugin URI: http://blog.zacharyarmstrong.com/2006/09/16/wordpress-trackback-for-pages-plugin/
Description:  Allow users to do Trackbacks on Pages
Version: 0.2
Author: Zachary Armstrong
Author URI: http://blog.zacharyarmstrong.com
*/


function wptbp_createTBBox()
{
$form_trackback = '<input type="text" name="trackback_url" style="width: 415px" id="trackback" tabindex="7" value="'. str_replace("\n", ' ', $post->to_ping) .'" />';

if ('' != $post->pinged)
{
	$pings = '<p>'. __('Already pinged:') . '</p><ul>';
	$already_pinged = explode("\n", trim($post->pinged));
	foreach ($already_pinged as $pinged_url) {
		$pings .= "\n\t<li>" . wp_specialchars($pinged_url) . "</li>";
	}
	$pings .= '</ul>';
}
?>
<div class="dbx-box-wrapper">
<fieldset id="trackbacksdiv" class="dbx-box">
<div class="dbx-handle-wrapper">
<h3 class="dbx-handle"><?php _e('Trackbacks') ?></h3>
</div>
<div class="dbx-content-wrapper">
<div class="dbx-content"><?php _e('Send trackbacks to:'); ?> <?php echo $form_trackback; ?> (<?php _e('Separate multiple URLs with spaces'); ?>)
<?php
if ( ! empty($pings) )
	echo $pings;
?>
</div>
</div>
</fieldset>
</div>

<br/><div align="center">
<!-- please dont remove these unless you really really really want to -->
<!-- dont change --><img border="0" src="http://www.masterslate.org/buttons/1/6/button.png">&nbsp;&nbsp;&nbsp;&nbsp;
<!-- curr ver -  change --><img border="0" src="http://www.masterslate.org/buttons/1/8/button.png">&nbsp;&nbsp;&nbsp;&nbsp;
<!-- dont change --><img border="0" src="http://www.masterslate.org/buttons/1/7/button.png">
</div>
</div>
</div>
</fieldset>
<?php
}

function wptbp_spawnPinger()
{
	@do_all_pings();
}

add_action('dbx_page_advanced', 'wptbp_createTBBox');
add_action('save_post','wptbp_spawnPinger');
?>